package com.fare.taluo.util.crawl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fare.taluo.vo.core.StatisticsTotalEntityVO;

public class XmlUtil {
	public static String getCrawlGrabHistroyXMLshow(String tableName, List<StatisticsTotalEntityVO > chartVOs) {
		String XML = "<?xml version='1.0'?>"
				+ "<chart  palette='2' useRoundEdges='0' caption='"
				+ tableName
				+ "' shownames='1' showvalues='1' showSum='0' decimals='0' useRoundEdges='1' baseFont='Arial' baseFontSize='12' rotateYAxisName='0' labelDisplay='Rotate' slantLabels='1'><categories>";
		
		if (chartVOs != null && chartVOs.size() > 0) {
			for (StatisticsTotalEntityVO vo : chartVOs) {
				XML += "<category label='" + vo.getGrabdate() + "'/>";
			}
		} else {
			XML += "<category label=''/>";
		}
		XML += "</categories>";
		
		String color = "#F1683C";
		XML += "<dataset seriesName='数据量' anchorRadius='5' color='"+color+"' >";
		if (chartVOs.size() > 0) {
			for (StatisticsTotalEntityVO vo : chartVOs) {
				XML += "<set value='" + vo.getSourceDataSize()/(1024*1024) + "' />";
			}
		} else {
			 XML += "<set />";
		}
		XML += "</dataset>";
		
		XML += "</chart>";

		return XML;
	}
	
	//颜色控制
	public static Map<Integer, String> staticChartColors = new HashMap<Integer, String>();
	static {
		staticChartColors.put(0, "4A6FB1");
		staticChartColors.put(1, "A4483D");
		staticChartColors.put(2, "8DA71E");
		staticChartColors.put(3, "FF00FF");
		staticChartColors.put(4, "00FF00");
		staticChartColors.put(5, "3399CC");
		staticChartColors.put(6, "9900FF");
		staticChartColors.put(7, "CC3333");
	}
	
	private static Map<String, List<StatisticsTotalEntityVO>> convertMapsData(
			List<StatisticsTotalEntityVO> chartVOs) {
		Map<String, List<StatisticsTotalEntityVO>> xmlDatas = new HashMap<String, List<StatisticsTotalEntityVO>>();
		// 4、转成航班号对应list, 航班下的某一天数据可能为空
		for (StatisticsTotalEntityVO vo : chartVOs) {
			
		}
		return xmlDatas;
	}
}
